<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- jsp文件头和头部 -->
<%@ include file="../../system/admin/top.jsp"%>
</head>
<body>

	<!-- 检索  -->
	<form action="borrowmoney/list.do" method="post" name="Form" id="Form">
		<div class="con-form">
			<input autocomplete="off" id="nav-search-input" value="${pd.keyWord}"	type="text" name="keyWord" placeholder="这里输入关键词" class="input-search" />
			   开始日期 <input type="text" name="lastLoginStart" id="lastLoginStart" class="form_datetime date" value="${pd.lastLoginStart}" readonly="readonly">
                                        结束日期 <input type="text" name="lastLoginEnd" id="lastLoginEnd" class="form_datetime date" value="${pd.lastLoginEnd}" readonly="readonly">
			    <button class="search" onclick="search();" title="查询">查询</button>
			<!-- 检索  -->
		</div>
		<p class="operate">
			<c:if test="${QX.add == 1 }">
				<a class="create Operate" title="新增" onclick="add();">申请借款</a>
			</c:if>
		</p>

		<table>
			<colgroup>
				<col width="3%">
				<col width="5%">
				<col width="23%">
				<col width="9%">
				<col width="9%">
				<col width="9%">
				<col width="6%">
				<col width="13%">
				<col width="9%">
				<col width="10%">
			</colgroup>
			<thead>
				<tr>
					<th><input type="checkbox" id="zcheckbox"></th>
					<th class="center">序号</th>
					<th class="center">借款原因</th>
					<th class="center">借款人</th>
					<th class="center">借款部门</th>
					<th class="center">借款金额</th>
					<th class="center">借款方式</th>
					<th class="center">申请借款时间</th>
					<th class="center">借款状态</th>
					<th class="center">操作</th>
				</tr>
			</thead>
			<tbody>

				<!-- 开始循环 -->
				<c:choose>
					<c:when test="${not empty varList}">
						<c:if test="${QX.cha == 1 }">
							<c:forEach items="${varList}" var="var" varStatus="vs">
								<tr>
									<td>
										<input type='checkbox' name='ids' value="${var.bm_id}" />
									</td>
									<td class='center' style="width: 30px;">${vs.index+1}</td>
									<td><a style="color: #ff8810"	href="${basePath}borrowmoney/goDetail.do?bm_id=${var.bm_id }">${var.bm_reason}</a></td>
									<td>${var.USERNAME}</td>
									<td>${var.department_name}</td>
									<td>${var.bm_amount}</td>
									<td>
										<c:if test="${var.bm_way == 0}">现金</c:if> 
										<c:if test="${var.bm_way == 1}">转账</c:if> 
										<c:if test="${var.bm_way == 2}">其它</c:if>
									</td>
									<td><fmt:formatDate value="${var.bm_time}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
									<td><c:if test="${var.bm_status == 0}">保存</c:if> 
										<c:if test="${var.bm_status == 1}">提交流程</c:if> 
										<c:if test="${var.bm_status == 2}">审核驳回</c:if> 
										<c:if test="${var.bm_status == 3}">审核通过</c:if> 
										<c:if test="${var.bm_status == 4}">确认借款</c:if> 
										<c:if test="${var.bm_status == 5}">确认还款</c:if></td>
									<td style="width: 30px;" class="center">
										<c:if test="${QX.edit != 1 && QX.del != 1 }">
												<div class="operate-more">
													<span class='operate-true'></span>
												</div>
										</c:if> 
										<c:if test="${QX.edit == 1  && var.bm_status == 0  &&  pd.userId==var.user_id}">
											<p class="operate">
												<a title="编辑" onclick="edit('${var.bm_id}')" class="revise Operate" target="opFrame">编辑</a> 
												<%-- <a title="提交流程" onclick="submissionProcess('${var.bm_id}');" class="revise Operate" ></a> --%>
											</p>
										</c:if> 
										<c:if test="${QX.del == 1  && var.bm_status == 3}">
											<p class="operate">
												<a title="确认借款" onclick="sureRemittance('${var.bm_id}');" class="revise Operate">确认借款</a>
											</p>
										</c:if> <c:if test="${QX.del == 1  && var.bm_status == 4}">
											<p class="operate">
												<a title="确认还款" onclick="sureReimbursement('${var.bm_id}');" class="revise Operate">确认还款</a>
											</p>
										</c:if>
									</td>
								</tr>

							</c:forEach>
						</c:if>
						<c:if test="${QX.cha == 0 }">
							<tr>
								<td colspan="100" class="center">您无权查看</td>
							</tr>
						</c:if>
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center">没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
			</tbody>
		</table>

		<!--分页器-->
		<div class="branchPage">${page.pageStr}</div>
	</form>

	<!-- 返回顶部  -->
	<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse"> <i class="icon-double-angle-up icon-only"></i>
	</a>
	<script type="text/javascript">
		
		
		//检索
		function search(){
			$("#Form").submit();
		}
		
		
		//新增
		function add(){
			$("#zhongxin",domObj).show();
			$("#zhongxin iframe",domObj).attr("src","<%=basePath%>borrowmoney/goAdd.do");
		}
		
		//修改
		function edit(Id){
			$("#zhongxin",domObj).show();
			$("#zhongxin iframe",domObj).attr("src","<%=basePath%>borrowmoney/goEdit.do?bm_id="+Id);
		}
		
	
		
		function submissionProcess(Id){
				var message = confirm('您确认提交流程吗?');
				if(message) {
					var url = "<%=basePath%>borrowmoney/updateStatus.do?bm_id="+Id+"&bm_status=1&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data == "success"){
							//刷新列表页面
							location.href='<%=basePath%>borrowmoney/list.do';
						}
					});
				}
		}
				
				
				
		//确认借款
		function sureRemittance(Id){
			$.confirm('请仔细核对，确认已借款吗?',null,function(type){
		        if(type==='yes'){
					var url = "<%=basePath%>borrowmoney/updateStatus.do?bm_id="+Id+"&bm_status=4&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data == "success"){
							//刷新列表页面
							location.href='<%=basePath%>borrowmoney/list.do';
						}
					});
		        }else{
		           //do Nothing
		        }
		        this.hide();
		    });
		}
		
		
		//确认打款
		function sureReimbursement(Id){
			$.confirm('请仔细核对，确认已还款吗?',null,function(type){
		        if(type==='yes'){
					var url = "<%=basePath%>borrowmoney/updateStatus.do?bm_id="+Id+"&bm_status=5&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data == "success"){
							//刷新列表页面
							location.href='<%=basePath%>borrowmoney/list.do';
						}
					});
		        }else{
		           //do Nothing
		        }
		        this.hide();
		    });
		}
		
		
		$(function() {
			//日期插件
			$(".form_datetime").datetimepicker( {
			     autoclose:true,
			     format: "yyyy-mm-dd",
			     language: 'cn',
			     clearBtn:true,
			     todayHighlight: true
			});
			
		});
		</script>


</body>
</html>

